home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / findprt / findfrst.frm < prev    next >
Text File  |  1995-05-07  |  4KB  |  141 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Searching with FindFirst method on a whole string or partial string"
  4.    ClientHeight    =   4020
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1500
  7.    ClientWidth     =   7365
  8.    Height          =   4425
  9.    Left            =   1035
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4020
  12.    ScaleWidth      =   7365
  13.    Top             =   1155
  14.    Width           =   7485
  15.    Begin CommandButton Command2 
  16.       Caption         =   "Push to Clear list"
  17.       Height          =   495
  18.       Left            =   360
  19.       TabIndex        =   7
  20.       Top             =   3120
  21.       Width           =   1695
  22.    End
  23.    Begin Frame Frame1 
  24.       Height          =   1935
  25.       Left            =   2760
  26.       TabIndex        =   3
  27.       Top             =   240
  28.       Width           =   2415
  29.       Begin OptionButton Option2 
  30.          Caption         =   "Partial title"
  31.          Height          =   495
  32.          Left            =   240
  33.          TabIndex        =   5
  34.          Top             =   1080
  35.          Value           =   -1  'True
  36.          Width           =   2055
  37.       End
  38.       Begin OptionButton Option1 
  39.          Caption         =   "Whole title"
  40.          Height          =   495
  41.          Left            =   240
  42.          TabIndex        =   4
  43.          Top             =   360
  44.          Width           =   2055
  45.       End
  46.    End
  47.    Begin ListBox List1 
  48.       Height          =   1200
  49.       Left            =   2400
  50.       TabIndex        =   2
  51.       Top             =   2520
  52.       Width           =   4695
  53.    End
  54.    Begin TextBox Text1 
  55.       Height          =   495
  56.       Left            =   5520
  57.       TabIndex        =   0
  58.       Top             =   1080
  59.       Width           =   1455
  60.    End
  61.    Begin CommandButton Command1 
  62.       Caption         =   "Push to Find"
  63.       Height          =   495
  64.       Left            =   5520
  65.       TabIndex        =   1
  66.       Top             =   1800
  67.       Width           =   1455
  68.    End
  69.    Begin Label Label3 
  70.       Caption         =   "Enter string below to search on:"
  71.       Height          =   615
  72.       Left            =   5520
  73.       TabIndex        =   9
  74.       Top             =   360
  75.       Width           =   1455
  76.    End
  77.    Begin Label Label2 
  78.       Caption         =   "Select an option of how you want to search for a title(ie Search on the 'Whole title' or search on the 'Partial title' or first letter or of the title)."
  79.       Height          =   1455
  80.       Left            =   360
  81.       TabIndex        =   8
  82.       Top             =   360
  83.       Width           =   2175
  84.    End
  85.    Begin Label Label1 
  86.       Caption         =   "Results of Search ---->"
  87.       Height          =   375
  88.       Left            =   240
  89.       TabIndex        =   6
  90.       Top             =   2520
  91.       Width           =   2055
  92.    End
  93. End
  94. Dim a$
  95. Dim c$
  96.  
  97. Sub Command1_Click ()
  98.  Dim db As database
  99.  Dim ds As dynaset
  100.  
  101.  Set db = OpenDatabase("C:\vb\biblio.mdb")
  102.  Set ds = db.CreateDynaset("titles")
  103.  
  104.  If option2.Value = True Then
  105.   a$ = Trim$(text1.Text) + "*"  '*** or
  106.   c$ = "[title] like '" & a$ & "'"
  107.  ElseIf option1.Value = True Then
  108.   a$ = Trim$(text1.Text)      '*** if this one, use '=' and not 'like' below
  109.   c$ = "[title] = '" & a$ & "'"
  110.  End If
  111.  
  112.  ds.FindFirst c$
  113.  
  114. Do Until ds.NoMatch
  115.  list1.AddItem " " & ds("Title")
  116.  ds.FindNext c$
  117. Loop
  118.  
  119.  
  120. End Sub
  121.  
  122. Sub Command2_Click ()
  123.  list1.Clear
  124.  text1.Text = ""
  125.  text1.SetFocus
  126. End Sub
  127.  
  128. Sub Option1_Click ()
  129.  option1.Value = True
  130.  option2.Value = False
  131.  
  132. End Sub
  133.  
  134. Sub Option2_Click ()
  135.  option2.Value = True
  136.  option1.Value = False
  137.  
  138.  
  139. End Sub
  140.  
  141.